// import axios from 'axios'
const admin = {
  state: {
    id: undefined
  },
  mutations: {
    SAVE_ADMIN_USER (state, {id}) {
      state.id = id
    },
    CLEAR_ADMIN_USER (state) {
      state.id = undefined
    }
  },
  actions: {
    async adminLogin (context, {name, password}) {
      let {data: {}} = await axios({

      })
      context.commit('SAVE_ADMIN_USER', {
        id: 1
      })
      localStorage.setItem('id', 1)
    },
    async adminLogout ({commit}) {
      commit('CLEAR_ADMIN_USER')
    },
    async getAdminInfo (context, obj) {
      context.commit('SAVE_ADMIN_USER', {
        id: localStorage.getItem('id')
      })
    }
  },
  getters: {
    'isAdminLogin' (state) {
      return !!state.id
    }
  }
}

export default admin
